<include file="../header" />
</head>
<body class="J_scroll_fixed">
<script type="text/javascript">
    $(function() {
        $("input[name=checkAll]").click(function() {
            var checkboxs = $("input.checkItem");
            if($("input[name=checkAll]").is(':checked')) {
                for(var i = 0 ;i<checkboxs.length;i++) {
                    checkboxs[i].checked = true;
                }
            }else{
                for(var i = 0 ;i<checkboxs.length;i++) {
                    checkboxs[i].checked = false;
                }
            }
        });

        $("button#upload").click(function(){
            //上传文件
            $.ajaxFileUpload({
                url:"{:U('activity/uploadImage')}",//处理图片脚本
                secureuri :false,
                fileElementId :'fileToUpload',//file控件id
                dataType : 'json',
                success : function (data, status){
                    $("input[name=signimgurl]").val(data);
                    $("img[name=preShow]").attr("src", data);
                },
                error: function(data, status, e){
                    alert(e);
                }
            })

        });

        $("button.btn_submit").click(function() {
            if ($("input[name=enterprise_name]").val() == "") {
                alert("【企业名称】不能为空");
                $("input[name=enterprise_name]").focus();
                return false;
            }

            if ($("input[name=enterprise_code]").val() == "") {
                alert("【企业代码】不能为空");
                $("input[name=enterprise_code]").focus();
                return false;
            }

            if ($("input[name=workorder_no_head]").val() == "") {
                alert("【企业前缀】不能为空");
                $("input[name=workorder_no_head]").focus();
                return false;
            }

            var checkboxs = $("input.checkItem");
            var id = "";
            for (var i = 0; i < checkboxs.length; i++) {
                if(id != ""){
                    id += ",";
                }
                if(checkboxs[i].checked == true){
                    id += "1";
                }else{
                    id += "0";
				}
            }
            $("input[name=orthosisStatusId]").val(id);

            $("button.btn_submit").hide();

        })

    })

</script>
<div class="wrap jj">
	<div class="common-form">
		<form method="post" class="form-horizontal J_ajaxForm" action="{:U('Enterprise/edit_post')}">
			<fieldset>
				<div class="control-group">
					<label class="control-label">LOGO图片:</label>
					<div class="controls">
						<input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
						<button type="button" class="btn btn-primary" id="upload">上传</button>
						<input type="hidden" name="signimgurl" value="{$enterprise.image_url}"/>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">LOGO预览:</label>
					<div class="controls">
						<img style="width: 100px" src="{$enterprise.image_url}" name="preShow"/>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">企业名称:</label>
					<div style="line-height: 30px; font-size: 1.2rem" class="controls">
						<input type="text" class="input" name="enterprise_name" value="{$enterprise.enterprise_name}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">企业代码:</label>
					<div class="controls">
						<input type="text" class="input" name="enterprise_code" value="{$enterprise.enterprise_code}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">企业前缀:</label>
					<div class="controls">
						<input type="text" class="input" name="workorder_no_head" value="{$enterprise.workorder_no_head}">
					</div>
				</div>

				<div class="control-group">
					<label class="control-label">角色:</label>
					<div class="controls">
						<foreach name="roles" item="vo">
							<label class="checkbox inline">
								<php>$role_id_checked=in_array($vo['id'],$role_ids)?"checked":"";</php>
								<input value="{$vo.id}" type="checkbox" name="role_id[]" {$role_id_checked}>{$vo.name}
							</label>
						</foreach>
					</div>
				</div>
				<hr class="half-rule">
				<table class="table table-hover table-bordered" id="viewTabs" style="width: 400px; margin-left: 90px">
					<thead>
					<tr>
						<th style="min-width: 10px; width: 10px"><input type="checkbox" name="checkAll"></th>
						<th style="min-width: 100px; width: 200px">矫形器流程</th>
					</tr>
					</thead>
					<tbody>
					<foreach name="list" item="vo">
						<tr>
							<php>
								$orthosisStatus_checked=($vo["status"] == 1)?"checked":"";
							</php>
							<td><input type="checkbox" class="checkItem" name="{$vo.status_id}" {$orthosisStatus_checked}></td>
							<td style="font-size: 1rem"><img style="height: 30px;" src="/Template/images/{$vo.name}亮.png"/> {$vo.name}</td>
						</tr>
					</foreach>
					</tbody>
				</table>
				<input type="hidden" name="orthosisStatusId" value="" style="width: 200px"/>

				<div class="control-group">
					<label class="control-label">上次更新:</label>
					<div style="line-height: 30px;color: #61a4de; font-size: 1rem" class="controls">
						[{$enterprise.update_time}] {$updateName}
					</div>
				</div>
			</fieldset>
			<div class="form-actions">
				<input type="hidden" name="id" value="{$id}" />
				<button type="submit" class="btn btn-primary btn_submit">更新</button>
				<a class="btn" href="{:u('Enterprise/index')}">返回</a>
			</div>
		</form>
	</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>